package com.turboconnard.display;

import java.util.Vector;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.RectShape;
import android.graphics.drawable.shapes.Shape;

public class Graphics {
	private Vector<Shape> _shapes;
	private Vector<Paint> _paints;
	private Paint _currentPaint;
	private Vector<Point> _pos;

	public Graphics() {
		_shapes = new Vector<Shape>();
		_paints = new Vector<Paint>();
		_pos = new Vector<Point>();
		_currentPaint = new Paint();
		// _currentPaint.setARGB(255, 255, 0, 255);
	}

	public void draw(Canvas pCanvas) {
	
		int count = 0;
		for (Shape ov : _shapes) {
			pCanvas.save();
			pCanvas.translate(_pos.get(count).x, _pos.get(count).y);
			ov.draw(pCanvas, _paints.get(count));
			pCanvas.restore();
			count++;
		}
	}

	public void beginFill(int pColor, double pAlpha) {
		int red = pColor >> 16;
		int greenBlue = pColor - (red << 16);
		int green = greenBlue >> 8;
		int blue = greenBlue - (green << 8);

		_currentPaint.setARGB((int) (pAlpha * 255), red, green, blue);
	}

	public void drawCircle(int pX, int pY, int pWidth, int pHeight) {
		OvalShape shape = new OvalShape();
		shape.resize(pWidth, pHeight);
		_shapes.add(shape);
		Paint p = new Paint(_currentPaint);
		_pos.add(new Point(pX,pY));
		_paints.add(p);
	}
	public void drawRect(int pX, int pY, int pWidth, int pHeight) {
		RectShape shape = new RectShape();
		shape.resize(pWidth, pHeight);
		_shapes.add(shape);
		Paint p = new Paint(_currentPaint);
		_pos.add(new Point(pX,pY));
		_paints.add(p);
	}

	public void clear() {
		_shapes.clear();
		_paints.clear();
		_pos.clear();
	};
}
